package chapter21.homework02;

public class MementoClint {
    public static void main(String[] args) {
        //创建角色，并设置初始状态100
        Role role=new Role();
        role.setState(100);
        //保存初始状态到memento，并存入Caretaker中
        Memento memento = role.saveStateMemento();
        Caretaker caretaker=new Caretaker();
        caretaker.add(memento);
        //状态改变
        role.setState(50);
        System.out.println("妖怪打完了");
        //获取保存的状态
        Memento memento1 = caretaker.getMemento(0);
        //对角色进行回档，状态设置
        role.getStateMemento(memento1);
        System.out.println(role.getState());
    }
}
